home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60src.lha / Vim / vim60 / src / testdir / test11.in < prev    next >
Encoding:
Text File  |  2000-12-02  |  2.6 KB  |  71 lines

  1. Tests for autocommands:
  2. - FileWritePre        writing a compressed file
  3. - FileReadPost        reading a compressed file
  4. - BufNewFile        reading a file template
  5. - BufReadPre        decompressing the file to be read
  6. - FilterReadPre        substituting characters in the temp file
  7. - FilterReadPost    substituting characters after filtering
  8. - FileReadPre        set options for decompression
  9. - FileReadPost        decompress the file
  10.  
  11. Note: This test will fail if "gzip" is not available.
  12. $GZIP is made empty, "-v" would cause trouble.
  13.  
  14. STARTTEST
  15. :so small.vim
  16. :let $GZIP = ""
  17. :set bin
  18. :au FileWritePre    *.gz   '[,']!gzip
  19. :au FileWritePost   *.gz   undo
  20. :/start of testfile/,/end of testfile/w! Xtestfile.gz
  21. :au FileReadPost    *.gz   '[,']!gzip -d
  22. :$r Xtestfile.gz                " Read and decompress the testfile
  23. :?startstart?,$w! test.out      " Write contents of this file
  24. :au BufNewFile      *.c    read Xtest.c
  25. gg/^end of testfile
  26. :/start of test.c/+1,/end of test.c/-1w! Xtest.c
  27. :e! foo.c                       " Will load Xtest.c
  28. :au FileAppendPre   *.out  '[,']s/new/NEW/
  29. :au FileAppendPost  *.out  !cat Xtest.c >>test.out
  30. :w>>test.out                    " Append it to the output file
  31. :au! FileAppendPre
  32. :" setup autocommands to decompress before reading and re-compress afterwards
  33. :au BufReadPre      *.gz   !gzip -d <afile>
  34. :au BufReadPre      *.gz   call rename(expand("<afile>:r"), expand("<afile>"))
  35. :au BufReadPost     *.gz   call rename(expand("<afile>"), expand("<afile>:r"))
  36. :au BufReadPost     *.gz   !gzip <afile>:r
  37. :e! Xtestfile.gz                " Edit compressed file
  38. :w>>test.out                    " Append it to the output file
  39. :au FilterReadPre   *.out  call rename(expand("<afile>"), expand("<afile>").".t")
  40. :au FilterReadPre   *.out  !sed s/e/E/ <afile>.t ><afile>
  41. :au FilterReadPre   *.out  !rm <afile>.t
  42. :au FilterReadPost  *.out  '[,']s/x/X/g
  43. :e! test.out                    " Edit the output file
  44. :23,$!cat
  45. :au! FileReadPre    *.gz   !gzip -d <afile>
  46. :au  FileReadPre    *.gz   call rename(expand("<afile>:r"), expand("<afile>"))
  47. :au! FileReadPost   *.gz   '[,']s/l/L/
  48. :$r Xtestfile.gz             " Read compressed file
  49. :w                           " write it, after filtering
  50. :qa!
  51. ENDTEST
  52.  
  53. startstart
  54. start of testfile
  55. line 2    Abcdefghijklmnopqrstuvwxyz
  56. line 3    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  57. line 4    Abcdefghijklmnopqrstuvwxyz
  58. line 5    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  59. line 6    Abcdefghijklmnopqrstuvwxyz
  60. line 7    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  61. line 8    Abcdefghijklmnopqrstuvwxyz
  62. line 9    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  63. line 10 Abcdefghijklmnopqrstuvwxyz
  64. end of testfile
  65.  
  66. start of test.c
  67. /*
  68.  * Here is a new .c file
  69.  */
  70. end of test.c
  71.